fix(kafka): [Queue Instrumentation 24] Read all baggage headers on consumers#5320
Draft
adinauer wants to merge 1 commit intofix/queue-instrumentation-kafka-context-handofffrom
Conversation
…nsumers
Pass every Kafka baggage header through trace continuation in both the
raw Kafka helper and the Spring Kafka record interceptor.
Previously both consumer paths used lastHeader("baggage"), which dropped
all earlier baggage values and could break interop with upstream OTel or
other W3C baggage producers. Reading the full header list preserves the
existing baggage context during queue trace continuation.
This was referenced Apr 22, 2026
Draft
Draft
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Queue Instrumentation)
📜 Description
Both Kafka consumer tracing paths only forwarded
lastHeader("baggage")intocontinueTrace(...).This change reads every
baggageheader from the record and passes the full list into trace continuation in:SentryKafkaConsumerTracingSentryKafkaRecordInterceptorIt also adds tests covering multiple baggage headers for both implementations.
💡 Motivation and Context
Kafka records can legitimately carry multiple
baggageheaders. Reading only the last one drops earlier entries and can break distributed tracing interop with upstream OpenTelemetry or other W3C baggage producers.Passing the full header list preserves the existing baggage context during queue trace continuation.
💚 How did you test it?
./gradlew spotlessApply apiDump :sentry-kafka:test --tests='io.sentry.kafka.SentryKafkaConsumerTracingTest' :sentry-spring-jakarta:test --tests='io.sentry.spring.jakarta.kafka.SentryKafkaRecordInterceptorTest'📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None.
#skip-changelog